/**
 * There are <a href="https://github.com/thinkgem/jeesite">JeeSite</a> code generation
 */
package com.chlitina.store.modules.employee.entity;

import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.hibernate.validator.constraints.Length;

import com.chlitina.store.common.persistence.BaseEntity;
import com.chlitina.store.common.utils.excel.annotation.ExcelField;
import com.chlitina.store.modules.base.entity.StoreRole;
import com.chlitina.store.modules.sys.entity.Store;

/**
 * 雇员Entity
 * @author liujiang
 * @version 2013-06-16
 */
@Entity
@Table(name = "employee")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Employee extends BaseEntity {

	final public static int STATUS_WORKING = 0;
	final public static int STATUS_NONWORKING = 1;
	private static final long serialVersionUID = 1L;
	private Long id; 		// 编号
	private Store store; 		// 店面
	private StoreRole storeRole;//店面角色
	private String name; 	// 名字
	private int gender; //性别：0 - 女 1 - 男
	private Date birthday;// 剩余数量
	private String sfzh; //身份证号
	private String photo; //照片文件路径
	private float salary; //基本工资
	private String jzdz; //居住地址
	private String mobile; //电话号码
	private int status; //员工状态 0-在职 1-离职
	
	public Employee() {
		this.status = 0;
	}

	public Employee(Long id){
		this();
		this.id = id;
	}
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}
	
	@ManyToOne(cascade=CascadeType.REFRESH, fetch = FetchType.LAZY)
	@JoinColumn(name="STORE_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	@NotNull
	public Store getStore() {
		return store;
	}

	public void setStore(Store store) {
		this.store = store;
	}

	@ManyToOne(cascade=CascadeType.REFRESH, fetch = FetchType.LAZY)
	@JoinColumn(name="ROLE_ID")
	@NotFound(action = NotFoundAction.IGNORE)
	@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
	@NotNull
	public StoreRole getStoreRole() {
		return storeRole;
	}

	public void setStoreRole(StoreRole storeRole) {
		this.storeRole = storeRole;
	}
	
	@NotNull(message="员工姓名不能为空")
	@ExcelField(title="姓名", align=2, sort=10)
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getGender() {
		return gender;
	}

	public void setGender(int gender) {
		this.gender = gender;
	}
	@NotNull(message="生日不能为空")
	@ExcelField(title="生日", align=2, sort=20)
	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}
	
	@NotNull(message="身份证号不能为空")
	@ExcelField(title="身份证号", align=2, sort=30)
	public String getSfzh() {
		return sfzh;
	}

	public void setSfzh(String sfzh) {
		this.sfzh = sfzh;
	}

	public String getPhoto() {
		return photo;
	}

	public void setPhoto(String photo) {
		this.photo = photo;
	}

	public float getSalary() {
		return salary;
	}

	public void setSalary(float salary) {
		this.salary = salary;
	}

	public String getJzdz() {
		return jzdz;
	}

	public void setJzdz(String jzdz) {
		this.jzdz = jzdz;
	}

	@ExcelField(title="手机号码", align=2, sort=40)
	@NotNull(message = "手机号码不能为空")
	@Length(min =10, max = 12, message = "手机号码格式不正确")
	public String getMobile() {
		return mobile;
	}
	
	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}
	
}


